//
//  LDY_ReadViewController.m
//  ProjectOfBStage
//
//  Created by dlios on 15/11/13.
//  Copyright © 2015年 cuixin. All rights reserved.
//

#import "LDY_ReadViewController.h"
#import "Network.h"
#import "ReadingModel.h"

@interface LDY_ReadViewController ()

@property (nonatomic, retain) NSMutableArray *dataArr;

@property (nonatomic, retain) NSMutableArray *mainArr;

@property (nonatomic, retain) UICollectionView *readCollectionView;

@end

@implementation LDY_ReadViewController

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.dataArr = [NSMutableArray array];
        
        self.mainArr = [NSMutableArray array];
    }
    
    return self;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self dataHandle];
}


- (void)dataHandle
{
    
    
    [Network networkPOSTRequestWithURL:@"http://api2.pianke.me/read/columns" body:@"auth=&client=1&deviceid=7F95D47F-BF62-4528-B18E-EE921FFC5323&version=3.0.6" result:^(id result) {
        
        
        
        NSDictionary *dic = result;
        
        NSDictionary *dataDic = [dic objectForKey:@"data"];
        
        
        
        self.dataArr = [dataDic objectForKey:@"list"];
        
//        NSLog(@"%@", self.dataArr);
        
        for (NSDictionary *dic in self.dataArr) {
            
            
            ReadingModel *model = [ReadingModel modelWithDictionary:dic];
            
            
            [self.mainArr addObject:model];
            
//            NSLog(@"~~~~~%@", self.mainArr);
        }
        
        
        
    }];
}


- (void)creatCollectionView
{
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
    
<<<<<<< HEAD
    self.readCollectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, KWIDTH * 375, KHEIGHT * 667 - 64) collectionViewLayout:flowLayout];
    [self.view addSubview:self.readCollectionView];
    
    self.readCollectionView.delegate = self;
    self.readCollectionView.dataSource = self;
    
    self.readCollectionView.backgroundColor = [UIColor whiteColor];
    
    
    [self.readCollectionView registerClass:[LDY_ReadCollectionViewCell class] forCellWithReuseIdentifier:@"LDY_ReadCollectionViewCell"];
    
    /* 注册头尾视图 */
    [self.readCollectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"LDY_ReadCollectionReusableView"];
    
    
    /* 轮播图 */
    self.cycleScrollView = [[SDCycleScrollView alloc] initWithFrame:CGRectMake(0, 0, KWIDTH * 375, KHEIGHT * 200)];
    [self.readCollectionView addSubview:self.cycleScrollView];
    self.cycleScrollView.delegate = self;
    self.cycleScrollView.placeholderImage = [UIImage imageNamed:@"wait"];
    
    [self.cycleScrollView release];
    [flowLayout release];
    [self.readCollectionView release];

=======
//        self.readCollectionView = [UICollectionView alloc] initWithFrame:CGRectMake(0, 64, <#CGFloat width#>, <#CGFloat height#>) collectionViewLayout:<#(nonnull UICollectionViewLayout *)#>
>>>>>>> 7fa011eeb16ff1cacb7abceba48b98a575d628c5
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
